-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Rec2020 color space #42
base: main
Are you sure you want to change the base?
Conversation
Resolves linebender#20, now implementing all CSS Color Module Level 4 color spaces.
(2_785_571_537. / 1_677_558_947.) as f32, | ||
(-985_802_650. / 1_677_558_947.) as f32, | ||
(-122_209_940. / 1_677_558_947.) as f32, | ||
], | ||
[ | ||
(-4_638_020_506. / 37_238_079_773.) as f32, | ||
(42_187_016_744. / 37_238_079_773.) as f32, | ||
(-310_916_465. / 37_238_079_773.) as f32, | ||
], | ||
[ | ||
(-97_469_024. / 5_369_968_309.) as f32, | ||
(-3_780_738_464. / 37_589_778_163.) as f32, | ||
(42_052_799_795. / 37_589_778_163.) as f32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more lily-gilding here. Debatable usefulness, as the transfer function parameters are reals not representable as rationals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of picky micro-optimizations, otherwise looks good. Again, spot-checked the color pairs in the test against color.js.
|
||
fn transfer(x: f32) -> f32 { | ||
if x.abs() < Rec2020::B * 4.5 { | ||
x / 4.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be x * (1.0 / 4.5) for performance.
if x.abs() < Rec2020::B { | ||
x * 4.5 | ||
} else { | ||
(Rec2020::A * x.abs().powf(0.45) - Rec2020::A + 1.).copysign(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you group it so it's (Rec2020::A - 1.)
that's one fewer addition.
Oh, also please add your name to the AUTHORS list. |
Resolves #20, now implementing all CSS Color Module Level 4 color spaces.